//
//  UserSmallView.m
//  YiShangPin
//
//  Created by yishangpin2 on 15/3/9.
//  Copyright (c) 2015年 yishangpin2. All rights reserved.
//

#import "UserSmallView.h"
#import "AppDelegate.h"
#import "Collect.h"

@implementation UserSmallView{
    AppDelegate *delegate;
}


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
    
    delegate = [[UIApplication sharedApplication] delegate];
    
    if (delegate.CollectArray.count>=1) {
        
        [self.BigImage setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"fushi%d.jpg",[delegate.CollectArray[delegate.CollectArray.count-1] integerValue]-1000]] forState:0];
        
        if (delegate.CollectArray.count >= 2) {
            [self.oneImage setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"fushi%d.jpg",[delegate.CollectArray[delegate.CollectArray.count-2] integerValue]-1000]] forState:0];
        }
        if (delegate.CollectArray.count >= 3) {
            [self.twoImage setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"fushi%d.jpg",[delegate.CollectArray[delegate.CollectArray.count-3] integerValue]-1000]] forState:0];
        }
        if (delegate.CollectArray.count >= 4) {
            [self.theerImage setBackgroundImage:[UIImage imageNamed:[NSString stringWithFormat:@"fushi%d.jpg",[delegate.CollectArray[delegate.CollectArray.count-4] integerValue]-1000]] forState:0];
        }
        
    }
    else
    {
        [self.BigImage setTitle:@"No items" forState:0];
        [self.BigImage setTitleColor:[UIColor grayColor] forState:0];
        [self.BigImage setBackgroundImage:[UIImage imageNamed:@""] forState:0];
        [self.oneImage setBackgroundImage:[UIImage imageNamed:@""] forState:0];
        [self.twoImage setBackgroundImage:[UIImage imageNamed:@""] forState:0];
        [self.theerImage setBackgroundImage:[UIImage imageNamed:@""] forState:0];
    }

}

- (void)gotoCollect{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    if (delegate.CollectArray.count > 0) {
        Collect *collect = [storyboard instantiateViewControllerWithIdentifier:@"Collect"];
        [[delegate CurrentViewController] pushViewController:collect animated:YES];
    }
}

- (IBAction)clikeBig:(id)sender {
    [self gotoCollect];
}

- (IBAction)clickOne:(id)sender {
    [self gotoCollect];
}

- (IBAction)clickTwo:(id)sender {
    [self gotoCollect];
}

- (IBAction)clickTheer:(id)sender {
    [self gotoCollect];
}
@end
